#ifndef _CM_REGISTRYITEM_H
#define _CM_REGISTRYITEM_H

/******************************************************************************
** @file	cm_registryitem.h
** @author	Joel Chuca Condo
**
** @date	Sep 01, 2010
**
** @desc	This class allows the managment a set of WMI_Registry objects to 
**          save  and retrieve of the database
**          
**
******************************************************************************/

#include <wmi_reader.h>
#include "cm_scripts.h"
#include "sqlite3x.hpp"
#include <iostream>
#include "cm_common.h"

using namespace std;
using namespace sqlite3x;

class CMEXPORT CM_RegistryItem
{
public:

    /**
    * Default constructor
    */
    CM_RegistryItem();

    /**
    * Destructor
    */
    ~CM_RegistryItem();

    /**
    * Saves a collection of registry object of a computer in a instant of time 
    *
    * @param collectionId. The id of time to save a collection of results
    * @param shares. Is a collection of results of WMI_Registry objects
    * @retun a integer value indicating the success of the process
    */
    int 
    saveRegistries(int collectionId, WMI_Result<WMI_Registry>& registries);

    /**
    * Loads WMI_Registry objects to a empty collection of results pertaining 
    * to a time instant
    *
    * @param collectionId. The id of a instant time
    * @param shares. Is a empty collection of results of WMI_Registry objects
    * @retun a integer value indicating the success of the process
    */
    int 
    getRegistries(int collectionId, WMI_Result<WMI_Registry>& registries);

private:

    /**
    * Gets the last id of registry table 
    *
    * @retun int value. Is the last id of the registry table
    */
    int 
    getRegistryLastId();

    /**
    * Saves a WMI_Registry object into database 
    *
    * @param parentId. The parent registry id
    * @param collectionId. The id of time to save a collection of results
    * @param registry. The WMI_Registry pointer
    * @retun a integer value indicating the success of the process
    */
    int 
    saveRegistry(int parentId, int collectionId, WMI_Registry* registry, sqlite3_connection& con);

    /**
    * Saves a WMI_Value object into database 
    *
    * @param registryId. The parent registry id
    * @param value. The WMI_Registry pointer
    * @retun a integer value indicating the success of the process
    */
    int 
    saveValue(int registryId, WMI_Value& value, sqlite3_connection& con);
    
};

#endif